package com.xxx.system.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置类：登录拦截配置拦截哪些请求，哪些请求不走拦截器
        */
@Configuration//配置类
public class LoginInterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;//

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                //添加路径,拦截所有请求
                .addPathPatterns("/**")
                //排除路径,放行跟登录的请求 //放行跟注册相关的 //放行跟测试相关的
                .excludePathPatterns("/logininfo/login/**")
                //放行swagger
                .excludePathPatterns("/swagger-resources/**", "/webjars/**",
                        "/v2/**", "/swagger-ui/**")
                // /minio不是axios请求，不会携带token，登录拦截器中就直接响应toLogin，也不会经过axios后置拦截器，所以要排除
                .excludePathPatterns("/minio/**");
    }
}